/**
 * @计算一个二次方程
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>
#include <math.h>

void enternumber(void);

float a, b, c, x1, x2; 

int main(int argc, char *argv[]) {

	enternumber();

	float number = b * b - 4 * a * c;

	if (number >= 0) {
		x1 = (-b + sqrt(number)) / (2 * a);
		x2 = (-b - sqrt(number)) / (2 * a);
		printf("x1=%.2f, x2=%.2f\n", x1, x2);
	} else {
		printf("此方程无解\n"); 
	}
}

void enternumber(void) {
	printf("欢迎使用1元2此方程！\n");

	printf("请输入a：");
	a = GetFloat();

	printf("请输入b：");
	b  = GetFloat();

	printf("请输入c：");
	c = GetFloat();

	printf("\n%.0fx^2 + %.0fx + %.0f = 0\n", a, b, c);
}
